﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Samples.ServiceHosting.StorageClient;
using Microsoft.ServiceHosting.ServiceRuntime;
using System.Collections.Specialized;

namespace UlyssesAgenda.Repositories
{
    public class CloudStorageRepositoryBase
    {
        protected StorageAccountInfo blobStorageAccount;
        protected StorageAccountInfo tableStorageAccount;
        protected StorageAccountInfo queueStorageAccount;

        protected BlobStorage blobStorage = null;
        protected BlobContainer blobContainer = null;
        protected TableStorage tableStorage = null;
        
        public CloudStorageRepositoryBase(StorageAccountInfo blobAccountInfo,
            StorageAccountInfo queueAccountInfo,
            StorageAccountInfo tableAccountInfo)
        {
            tableStorageAccount = tableAccountInfo;
            blobStorageAccount = blobAccountInfo;
            queueStorageAccount = queueAccountInfo;
        }

        protected void InitBlobContainer(string containerName)
        {
            blobStorage = BlobStorage.Create(this.blobStorageAccount);
            blobContainer = blobStorage.GetBlobContainer(containerName);
            blobContainer.CreateContainer(new NameValueCollection(), ContainerAccessControl.Public);
        }

        protected void InitTableStorage(string tableName)
        {
            tableStorage = TableStorage.Create(this.tableStorageAccount);
            //tableStorage.TryCreateTable(tableName);
        }
    }
}
